package com.ruoyi.web.controller.barcode;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.BarcodeMenu;
import com.ruoyi.system.service.IBarcodeMenuService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 条码菜单Controller
 * 
 * @author ruoyi
 * @date 2025-03-25
 */
@RestController
@RequestMapping("/barcode/menu")
public class BarcodeMenuController extends BaseController
{
    @Autowired
    private IBarcodeMenuService barcodeMenuService;

    /**
     * 查询条码菜单列表
     */
    @PreAuthorize("@ss.hasPermi('barcode:menu:list')")
    @GetMapping("/list")
    public TableDataInfo list(BarcodeMenu barcodeMenu)
    {
        startPage();
        List<BarcodeMenu> list = barcodeMenuService.selectBarcodeMenuList(barcodeMenu);
        return getDataTable(list);
    }

    /**
     * 导出条码菜单列表
     */
    @PreAuthorize("@ss.hasPermi('barcode:menu:export')")
    @Log(title = "条码菜单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BarcodeMenu barcodeMenu)
    {
        List<BarcodeMenu> list = barcodeMenuService.selectBarcodeMenuList(barcodeMenu);
        ExcelUtil<BarcodeMenu> util = new ExcelUtil<BarcodeMenu>(BarcodeMenu.class);
        util.exportExcel(response, list, "条码菜单数据");
    }

    /**
     * 获取条码菜单详细信息
     */
    @PreAuthorize("@ss.hasPermi('barcode:menu:query')")
    @GetMapping(value = "/{ID}")
    public AjaxResult getInfo(@PathVariable("ID") Long ID)
    {
        return success(barcodeMenuService.selectBarcodeMenuByID(ID));
    }

    /**
     * 新增条码菜单
     */
    @PreAuthorize("@ss.hasPermi('barcode:menu:add')")
    @Log(title = "条码菜单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BarcodeMenu barcodeMenu)
    {
        return toAjax(barcodeMenuService.insertBarcodeMenu(barcodeMenu));
    }

    /**
     * 修改条码菜单
     */
    @PreAuthorize("@ss.hasPermi('barcode:menu:edit')")
    @Log(title = "条码菜单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BarcodeMenu barcodeMenu)
    {
        return toAjax(barcodeMenuService.updateBarcodeMenu(barcodeMenu));
    }

    /**
     * 删除条码菜单
     */
    @PreAuthorize("@ss.hasPermi('barcode:menu:remove')")
    @Log(title = "条码菜单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{IDs}")
    public AjaxResult remove(@PathVariable Long[] IDs)
    {
        return toAjax(barcodeMenuService.deleteBarcodeMenuByIDs(IDs));
    }
}
